package flc.ast.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.FrameBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.view.container.StkFrameLayout;

public class FrameAdapter extends StkProviderMultiAdapter<FrameBean> {
    public FrameAdapter() {
        super(8);
        addItemProvider(new FrameItemProvider());
    }

    private class FrameItemProvider extends BaseItemProvider<FrameBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_frame;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, FrameBean frameBean) {
            StkFrameLayout crl = baseViewHolder.getView(R.id.crl);
            if (baseViewHolder.getBindingAdapterPosition() == 0) {
                crl.setBackgroundResource(R.drawable.white_bg);
            } else {
                crl.setBackgroundColor(Color.parseColor(frameBean.getFrameColor()));
            }
            baseViewHolder.setVisible(R.id.flFrameSelector, frameBean.isSelected());
        }
    }
}
